package recite.word.client.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import recite.word.client.dto.word.*;
import recite.word.client.service.IWordService;
import recite.word.client.vo.word.DayWordIdVO;
import recite.word.client.vo.word.ReciteInfoVO;
import recite.word.client.vo.word.WordInfoVO;
import recite.word.client.vo.word.WordListVO;
import recite.word.service.base.common.request.BaseRequest;
import recite.word.service.base.common.response.ResponseResult;


@RestController
@RequestMapping("/client/word")
@Api(tags = "客户端【单词】controller")
public class WordController {
    @Autowired
    private IWordService wordService;

    @PostMapping("/wordList")
    @ApiOperation("单词列表")
    public ResponseResult<IPage<WordListVO>> wordList(@RequestBody BaseRequest<WordListDTO> dto){
        IPage<WordListVO> ans = wordService.wordList(dto);
        return ResponseResult.success(ans);
    }

    @PostMapping("/changeCollect")
    @ApiOperation("变更收藏状态")
    public ResponseResult changeCollect(@RequestBody BaseRequest<ChangeCollectDTO> dto) {
        wordService.changeCollect(dto);
        return ResponseResult.success("变更收藏状态成功");
    }

    @PostMapping("/getWordInfo")
    @ApiModelProperty("获取单词详情")
    public ResponseResult<WordInfoVO> getWordInfo(@RequestBody BaseRequest<WordInfoDTO> dto) {
        WordInfoVO ans = wordService.getWordInfo(dto);
        return ResponseResult.success(ans);
    }

    @PostMapping("/getReciteInfo")
    @ApiModelProperty("获取背单词的详情")
    public ResponseResult<ReciteInfoVO> getReciteInfo(@RequestBody BaseRequest<ReciteInfoDTO> dto) {
        ReciteInfoVO ans = wordService.getReciteInfo(dto);
        return ResponseResult.success(ans);
    }

    @PostMapping("/getDayWordIds")
    @ApiModelProperty("获取今天的单词id")
    public ResponseResult<DayWordIdVO> getDayWordIds() {
        DayWordIdVO ans = wordService.getDayWordIds();
        return ResponseResult.success(ans);
    }

    @PostMapping("/setWordStudy")
    @ApiModelProperty("设置单词已学习")
    public ResponseResult setWordStudy(@RequestBody BaseRequest<WordStudyDTO> dto) {
        wordService.setWordStudy(dto);
        return ResponseResult.success("设置成功");
    }

    @PostMapping("/setWordWrong")
    @ApiModelProperty("设置单词错误")
    public ResponseResult setWordWrong(@RequestBody BaseRequest<WordWrongDTO> dto){
        wordService.setWordWrong(dto);
        return ResponseResult.success("设置成功");
    }

}
